﻿#region Using Statements
using System;
using System.Collections.Generic;
#endregion

namespace DirectZZT.Shared.Scripting
{
    /// <summary>
    /// Defines mechanisms for an object that hosts scripts.
    /// </summary>
    public interface IScriptHost
    {
        /// <summary>
        /// Gets/sets the executor to use for executing scripts.
        /// </summary>
        IScriptExecutor ScriptExecutor { get; set; }
        /// <summary>
        /// Gets/sets the name of the script host.
        /// </summary>
        string Name { get; set; }

        /// <summary>
        /// Attaches a new script to this host.
        /// </summary>
        /// <param name="script">The script to attach.</param>
        /// <returns>Whether or not the operation was successful.</returns>
        bool AttachScript(IScript script);
        /// <summary>
        /// Detaches/removes a script from this host.
        /// </summary>
        /// <param name="script">The script to detach.</param>
        /// <returns>Whether or not the operation was successful.</returns>
        bool DetachScript(IScript script);
        /// <summary>
        /// Returns an enumerable that can be used to safely traverse through all the object's scripts.
        /// </summary>
        /// <returns></returns>
        IList<IScript> GetScripts();
        /// <summary>
        /// Sends an event to this host.
        /// </summary>
        /// <param name="eventName">The name of the event to send.</param>
        /// <param name="arguments">Optional arguments, appropriate for the event.</param>
        /// <returns>Whether or not the event could be dispatched.</returns>
        bool OnEvent(string eventName, params string[] arguments);
    }
}
